#include <iostream>
#include <vector>

using namespace std;
class Solution
{
public:
    int search(vector<int> nums, int target)
    {
        int left = 0, right = nums.size();

        while (left < right)
        {
            int mid = left + (right - left) / 2;
            if (target > nums[mid])
            {
                left = mid + 1;
            }
            else if (target < nums[mid])
            {
                right = mid;
            }
            else
            {
                return mid;
            }
        }

        return -1;
    }
};
int main()
{
    Solution s;
    cout << s.search({-1, 0, 3, 5, 9, 12}, 9) << endl;
    return 0;
}
